package com.itheima.controller;

import com.itheima.common.domain.*;
import com.itheima.pojo.po.StockBusiness;
import com.itheima.pojo.vo.PageResult;
import com.itheima.pojo.vo.R;
import com.itheima.service.StockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/quot")
public class StockController {
    @Autowired
    private StockService service;

    @GetMapping("/stock/business/all")
    public List<StockBusiness> getAll() {
        List<StockBusiness> list = service.findAll();
        return list;
    }

    @GetMapping("/index/all")
    public R<List<InnerMarketDomain>> innerIndexAll() {
        return service.innerIndexAll();
    }

    @GetMapping("/sector/all")
    public R<List<StockBlockDomain>> sectorAll() {
        return service.sectorAllLimit();
    }

    @GetMapping("/stock/increase")
    R<List<StockUpdownDomain>> stockIncreaseLimit() {
        return service.stockIncreaseLimit();
    }

    @GetMapping("/stock/all")
    R<PageResult<StockUpdownDomain>> StockPageSelect(Integer page, Integer pageSize) {

        return service.StockPageSelect(page, pageSize);

    }

    @GetMapping("/stock/updown/count")
    R<Map> upAndDownSelect() {

        return service.upAndDownSelect();

    }

    @GetMapping("/stock/export")
    public void stockExport(HttpServletResponse response, Integer page, Integer pageSize) {
        service.stockExport(response, page, pageSize);
    }

    @GetMapping("/stock/tradevol")
    public R<Map> stockTradeVol() {
        return service.stockTradeVol();
    }

    @GetMapping("/stock/updown")
    public R<Map> stockUpDown() {
        return service.stockUpDown();
    }
    @GetMapping("/stock/screen/time-sharing")
    public R<List<Stock4MinuteDomain>> stockScreenTimeSharing(@RequestParam("code") String stockCode){
        return service.stockScreenTimeSharing(stockCode);
    }
    @GetMapping("/stock/screen/dkline")
    public R<List<Stock4EvrDayDomain>> StockScreenDkLine(@RequestParam("code") String stockCode){
        return service.stockScreenDkLine(stockCode);
    }
}
